package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotEmployeeTurn;
import com.gaohe.hotal.service.IHotEmployeeTurnService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工日轮班Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/turn")
public class HotEmployeeTurnController extends BaseController
{
    @Autowired
    private IHotEmployeeTurnService hotEmployeeTurnService;

    /**
     * 查询员工日轮班列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:turn:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotEmployeeTurn hotEmployeeTurn)
    {
        startPage();
        List<HotEmployeeTurn> list = hotEmployeeTurnService.selectHotEmployeeTurnList(hotEmployeeTurn);
        return getDataTable(list);
    }

    /**
     * 导出员工日轮班列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:turn:export')")
    @Log(title = "员工日轮班", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotEmployeeTurn hotEmployeeTurn)
    {
        List<HotEmployeeTurn> list = hotEmployeeTurnService.selectHotEmployeeTurnList(hotEmployeeTurn);
        ExcelUtil<HotEmployeeTurn> util = new ExcelUtil<HotEmployeeTurn>(HotEmployeeTurn.class);
        util.exportExcel(response, list, "员工日轮班数据");
    }

    /**
     * 获取员工日轮班详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:turn:query')")
    @GetMapping(value = "/{turnId}")
    public AjaxResult getInfo(@PathVariable("turnId") Long turnId)
    {
        return success(hotEmployeeTurnService.selectHotEmployeeTurnByTurnId(turnId));
    }

    /**
     * 新增员工日轮班
     */
    @PreAuthorize("@ss.hasPermi('hotal:turn:add')")
    @Log(title = "员工日轮班", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotEmployeeTurn hotEmployeeTurn)
    {
        return toAjax(hotEmployeeTurnService.insertHotEmployeeTurn(hotEmployeeTurn));
    }

    /**
     * 修改员工日轮班
     */
    @PreAuthorize("@ss.hasPermi('hotal:turn:edit')")
    @Log(title = "员工日轮班", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotEmployeeTurn hotEmployeeTurn)
    {
        return toAjax(hotEmployeeTurnService.updateHotEmployeeTurn(hotEmployeeTurn));
    }

    /**
     * 删除员工日轮班
     */
    @PreAuthorize("@ss.hasPermi('hotal:turn:remove')")
    @Log(title = "员工日轮班", businessType = BusinessType.DELETE)
	@DeleteMapping("/{turnIds}")
    public AjaxResult remove(@PathVariable Long[] turnIds)
    {
        return toAjax(hotEmployeeTurnService.deleteHotEmployeeTurnByTurnIds(turnIds));
    }
}
